from flask import jsonify
from app.libs.redprint import RedPrint
from app.validators.inspection import (
    EventListForm,
    EventDetailForm,
    EventMarkForm,
    IgnoreStrategyListForm,
    IgnoreStrategyAddForm,
    IgnoreStrategyModifyForm,
    IgnoreStrategyDeleteForm,
)
from app.handler.v2_inspection import (
    EventListHandler,
    EventDetailHandler,
    IgnoreStrategiesHandler,
    MarkHandler
)

api = RedPrint("inspection")


@api.route("/events/list", methods=["GET"])
def event_list():
    form = EventListForm().validate_for_api()
    return jsonify(EventListHandler().event_list(form))


@api.route("/events/detail", methods=["GET"])
def event_detail():
    form = EventDetailForm().validate_for_api()
    return jsonify(EventDetailHandler().event_detail(form))


@api.route("/events/mark", methods=["POST"])
def event_mark():
    form = EventMarkForm().validate_for_api()
    return jsonify(MarkHandler().mark(form))


@api.route("/ignore-strategies/list", methods=["GET"])
def ignore_strategies():
    form = IgnoreStrategyListForm().validate_for_api()
    return jsonify(IgnoreStrategiesHandler().list(form))


@api.route("/ignore-strategies/add", methods=["POST"])
def ignore_strategies_add():
    form = IgnoreStrategyAddForm().validate_for_api()
    return jsonify(IgnoreStrategiesHandler().add(form))


@api.route("/ignore-strategies/modify", methods=["POST"])
def ignore_strategies_modify():
    form = IgnoreStrategyModifyForm().validate_for_api()
    return jsonify(IgnoreStrategiesHandler().modify(form))


@api.route("/ignore-strategies/delete", methods=["POST"])
def ignore_strategies_delete():
    form = IgnoreStrategyDeleteForm().validate_for_api()
    return jsonify(IgnoreStrategiesHandler().delete(form))
